package com.mentaleye.dal.dao.mybatis;

import com.mentaleye.dal.dao.StudentsDao;
import com.mentaleye.dal.model.Students;
import com.mentaleye.dal.model.StudentsExample;
import com.mentaleye.dal.service.StudentsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class StudentsDaoImpl extends BaseDao implements StudentsDao {

	@Autowired
	private StudentsMapper dataMapper;

	@Override
	public boolean insertData(Students data) {
		boolean isSuccess=false;
		if(this.dataMapper.insert(data)>0){
			isSuccess=true;
		}
		return isSuccess;
	}

	@Override
	public boolean insertByList(List<Students> dataList) {
		boolean isSuccess=false;
		if(this.dataMapper.insertByList(dataList)>0){
			isSuccess=true;
		}
		return isSuccess;
	}
	
	@Override
	public boolean updateData(Students data) {
		boolean isSuccess=false;
		if(this.dataMapper.updateByPrimaryKey(data)>0){
			isSuccess=true;
		}
		return isSuccess;
	}

	public boolean updateDataBySelective(Students data,StudentsExample example) {
		boolean isSuccess=false;
		if(this.dataMapper.updateByExampleSelective(data, example)>0){
			isSuccess=true;
		}
		return isSuccess;
	}

	@Override
	public boolean updateStateByMap(Map<String, Object> map) {
		boolean isSuccess=false;
		if(this.dataMapper.updateStateByMap(map)>0){
			isSuccess=true;
		}
		return isSuccess;
	}
	
	@Override
	public boolean deleteByExample(StudentsExample example) {
		boolean isSuccess=false;
		if(this.dataMapper.deleteByExample(example)>0){
			isSuccess=true;
		}
		return isSuccess;
	}

	@Override
	public List<Students> getListByExample(StudentsExample example) {
		return this.dataMapper.selectByExample(example);
	}

	@Override
	public List<Map<String, Object>> getListByMap(Map<String, Object> map) {
		return this.dataMapper.getListByMap(map);
	}

	@Override
	public List<Students> selectStuByMap(Map<String, Object> map) {
		return dataMapper.selectAllStudentByMap(map);
	}

	public List<Students> selectListByState(Integer state){
		return dataMapper.selectListByState(state);
	}
}
